
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>

<title>View your cart</title>
<script>
    $(document).ready(function() {
        $("#cartTable").load("ServletViewCart");
        setInterval('$("#cartTable").load("ServletViewCart")', 5000);
    });

    var req = null;
    function removeProduct() {

        if (window.XMLHttpRequest) {
            req = new XMLHttpRequest();
        } else if (window.ActiveXObject) {
            req = new ActiveXObject("Microsfot.XMLHTTP");
        }

        req.onreadystatechange = handleStateChange;
        yourvalue = document.getElementById("pId").value;
        req.open("GET", "ServletRemoveProductFromCart?pId" + yourvalue, true);
        req.send(null);

    }

    function handleStateChange() {

        if (req.readyState === 4) {
            xmlvalue = req.responseText;
            alert(xmlvalue);
            $("#main").load("view_cart.jsp");
        }
    }

    function removeAll() {
        alert("removeAll");
    }
</script>

<div>	
    <center>
        <form method="GET" action="ServletResetCart">
            <input type="submit" value ="Remove All" onclick="removeAll()">
        </form>


        <table border="1" id="cartTable">
        </table>

        <input type="button" value ="Checkout" onclick="">
    </center>
</div>
